import request from '/@/utils/request';

export const genText = (content: object) => {
	return request({
		url: '/knowledge/chat/generate/text',
		method: 'post',
		data: content,
	});
};

export const genTts = (prompt: String) => {
	return request({
		url: '/knowledge/chat/generate/tts',
		method: 'post',
		data: { prompt },
	});
};

export const genImage = (params: {
	prompt: string;
	negativePrompt?: string;
	imageSize: string;
	batchSize: number;
	seed?: number | string;
	numInferenceSteps: number;
	guidanceScale: number;
	image?: string; // 单张图片（兼容旧版本）
	images?: string[]; // 多张图片（OpenRouter）
	model: string;
}) => {
	return request({
		url: '/knowledge/completions/image',
		method: 'post',
		data: params,
	});
};

export interface VideoCompletionParams {
	model: string;
	imageSize: string;
	seed?: number;
	negativePrompt?: string;
	prompt: string;
	image?: string;
}

export const generateVideoCompletion = (params: VideoCompletionParams) => {
	return request({
		url: '/knowledge/completions/video',
		method: 'post',
		data: params,
	});
};

export const getVideoCompletionStatus = (requestId: string, modelName: string) => {
	return request({
		url: `/knowledge/completions/video/status`,
		params: {
			requestId,
			modelName,
		},
		method: 'get',
	});
};

export interface VoiceCompletionParams {
	input: string;
	model: string;
	voice?: string;
	speed?: number; // Range: 0.25 <= x <= 4, default: 1
	gain?: number; // Range: -10 <= x <= 10, default: 0
}

// mock 数据：  return { data: 'https://audio.transistor.fm/m/shows/15/dai/67e8213447a11492c2bd33d777d596bf.mp3' };
export const genAudio = (params: VoiceCompletionParams) => {
	return request({
		url: '/knowledge/completions/voice',
		method: 'post',
		data: params,
	});
};

export interface AiFuncSubmitParams {
	funcName: string;
	[key: string]: any; // 允许其他任意表单数据
}

export const submitAiFunc = (params: AiFuncSubmitParams) => {
	return request({
		url: '/knowledge/aiFunc/submit',
		method: 'post',
		data: params,
	});
};
